<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // Object.defineProperties(target,options)     定义对象的属性修饰(定义一个或多个)
    // target 目标对象
    // options  (对象)可以定义对象的属性和属性描述的 {key:desc,key:desc}

    var zhang = {};
    Object.defineProperties(zhang, {
        "name": {
            value: "张三",
            writable: false,
            enumerable: false,
            configurable: false,
        },
        "age": {
            value: "18",
            writable: true,
            enumerable: true,
            configurable: true,
        },
        "height": {
            value: "183cm",
            writable: false,
            enumerable: false,
            configurable: false,
        },
        "weight": {
            value: "80kg",
            writable: false,
            enumerable: false,
            configurable: false,
        }
    })

    // Object.defineProperty(zhang, "name", {
    //     value: "李四",
    //     configurable: true,
    //     writable: true,
    //     enumerable: true,
    // })
    // console.log(zhang);




    // 如何获取对象的属性修饰
    // Object.getOwnPropertyDescriptor(target,key)   => 对象属性名获取对象的属性修饰 => 返回修饰对象
    // Object.getOwnPropertyDescriptors(target)     => 获取对象所有属性的修饰 => 对象(每一个属性的修饰)

    // console.log(Object.getOwnPropertyDescriptor(zhang, "name"));
    // console.log(Object.getOwnPropertyDescriptor(zhang, "age"));

    // console.log(Object.getOwnPropertyDescriptors(zhang));



    // 字符串
    var str = new String("hello");
    console.log(Object.getOwnPropertyDescriptors(str));




</script>

</html>